---
layout: m1x_rest
title: Testing REST Resources
---

<p>Three steps are required for utilizing REST API resources:</p>
<ul>
	<li><a href="http://www.magentocommerce.com/api/rest/authentication/oauth_authentication.html" title="OAuth Authentication">Authenticate the user</a> (receive the access token for further steps);</li>
	<li>Configure the <a href="http://www.magentocommerce.com/api/rest/permission_settings/roles_configuration.html" title="REST Roles Configuration">permissions for operations</a>和<a href="http://www.magentocommerce.com/api/rest/permission_settings/attributes_configuration.html" title="REST Attributes Configuration">attributes</a> for the type of the user;</li>
	<li>Make an API call.</li>
</ul>



<p>The following headers are required for the call:</p>
<ul>
	<li>Authorization</li>
	<li>Version</li>
	<li>Accept</li>
	<li>Content-type</li>
</ul>


<p>The following parameters must be provided in the Authorization header for the call:</p>
<ul>
	<li>oauth_signature_method</li>
	<li>oauth_version</li>
	<li>oauth_nonce</li>
	<li>oauth_timestamp</li>
	<li>oauth_consumer_key</li>
	<li>oauth_token</li>
	<li>oauth_signature</li>
</ul>


<h4><a name="TestingRESTResourceswithRESTClientsonDifferentBrowsers-TestingRESTresourceswiththeRESTClienthttps%3A%2F%2Faddons.mozilla.org%2FenUS%2Ffirefox%2Faddon%2Frestclient%2FpluginfortheMozillaFirefoxbrowser."></a>Testing REST resources with the <a href="https://addons.mozilla.org/en-US/firefox/addon/restclient/">REST Client</a> plugin for the Mozilla Firefox browser.</h4>

<ol>
	<li>Open the REST Client.</li>
	<li>From the Authentication drop-down, select <b>OAuth</b>.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test1.png" style="border: 1px solid black"/></li>
	<li>In the OAuth window, on the Signature for the request tab, fill in the following fields:<br/>
	<ul>
		<li><b>Consumer key</b>: Enter the <b>Key</b> value provided when you created the consumer in Magento Admin Panel.</li>
		<li><b>Consumer secret</b>: Enter the <b>Secret</b> value provided when you created the consumer in Magento Admin Panel.</li>
		<li><b>Access token</b>: Enter the oauth_token value received when you authenticated the application.</li>
		<li><b>Access token secret</b>: Enter the oauth_token_secret value received when you authenticated the application.</li>
	</ul>
	</li>
	<li>On the OAuth setting tab, define the following options:
		<img src="{{ site.baseurl }}/common/images/m1x/rest_test_oauth_tab.png" width="600" style="border: 1px solid black"/>
	<ul>
		<li><b>Signature Methods</b>: From the drop-down list, select which method will be used for signatures (HMAC-SHA1 or  PLAINTEXT).</li>
		<li><b>oAuth Version</b>: From the drop-down list, select the <b>1.0</b> option (REST API supports OAuth 1.0a).</li>
		<li>Leave the <b>Realm</b>, <b>oAuth Nonce</b>,以及<b>oAuth Timestemp</b> values set by default.</li>
	</ul>
	</li>
	<li>Click <b>Save</b> and wait for the confirmation dialog to close.<br/>
	<li>返回到 the Signature for the request tab and select <b>Insert &gt; Insert as header</b>.
			<img src="{{ site.baseurl }}/common/images/m1x/rest_test_insert.png" width="600" style="border: 1px solid black"/>
		<p>An authorization header is created on the main page of REST Client. </p>
		<img src="{{ site.baseurl }}/common/images/m1x/rest_test_authheader.png" width="600" style="border: 1px solid black"/>

	</li>

<b>NOTE</b>: Click the header with authorization data and click <b>Auto refresh</b> in the opened pop-up in order to generate new values for oauth_nonce, oauth_timestamp, and oauth_signature at each request.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test3.png" style="border: 1px solid black"/></span></li>
	<li>From the <b>Headers</b> drop-down, select <b>Custom Header</b>.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test4.png" style="border: 1px solid black"/></span></li>
	<li>In the <b>Request Header</b> window, enter "Content-Type" in the <b>Name</b> field and "text/xml" in the <b>Value</b> field (if you want to use the XML data format). To use the JSON request data format, enter application/json instead of the text/xml value.</li>
	<li>Click <b>Okay</b>.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test5.png" style="border: 1px solid black"/></span></li>
</ol>




<p><b>Example: Retrieving the List of Products</b></p>

<ol>
	<li>From the <b>Method</b> drop-down list, select the <b>GET</b> option.</li>
	<li>In the <b>URL</b> field, enter the following URL: <a href="http://magentohost/api/rest/products">http://magentohost/api/rest/products</a>. You can limit the number of products returned in the response. To set the limit to 4, enter the following URL: <a href="http://magentohost/api/rest/products?limit=4">http://magentohost/api/rest/products?limit=4</a></li>
	<li>Click <b>Send</b>. Information about all products will be displayed in the response body. Example is as follows:<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test6.png" style="border: 1px solid black"/></span></li>
</ol>



<h4><a name="TestingRESTResourceswithRESTClientsonDifferentBrowsers-TestingRESTresourceswiththeAdvancedRESTClienthttps%3A%2F%2Fchrome.google.com%2Fwebstore%2Fdetail%2FhgmloofddffdnphfgcellkdfbfbjelooforGoogleChromebrowser."></a>Testing REST resources with the <a href="https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjeloo">Advanced REST Client</a> for Google Chrome browser.</h4>

<ol>
	<li>Open the Advanced REST Client Application.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test7.png" style="border: 1px solid black"/></span></li>
	<li>In the <b>Headers</b> box, select the <b>Form</b> tab.</li>
	<li>In the first field, start typing <em>authorization</em>. An <b>Authorization</b> popup appears. Click it.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test8.png" style="border: 1px solid black"/></span></li>
	<li>When you click the fields next to the Authorization header, the <b>Construct</b> link appears. Click it to configure OAuth authentication.</li>
	<li>The Authorization window opens. Select the OAuth tab.<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test9.png" style="border: 1px solid black"/></span></li>
	<li>In the <b>Type</b> group of options, select the <b>Signed Request</b> option.</li>
	<li>In the <b>signature method</b> group of options, select which method will be used for signatures (HMAC-SHA1 or  PLAINTEXT).</li>
	<li>Fill in the following data:<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test10.png" style="border: 1px solid black"/></span>
	<ul>
		<li><b>Consumer key</b>: Enter the <b>Key</b> value provided when you created the consumer in Magento Admin Panel.</li>
		<li><b>Consumer secret</b>: Enter the <b>Secret</b> value provided when you created the consumer in Magento Admin Panel.</li>
		<li><b>Access Token</b>: Enter the oauth_token value received when you authenticated the application.</li>
		<li><b>Access Token Secret</b>: Enter the oauth_token_secret value received when you authenticated the application.</li>
	</ul>
	</li>
	<li>Click <b>OK</b>.<br/>
<b>NOTE</b>: Advanced REST Client does not save the <b>Consumer secret</b>和<b>Access Token Secret</b> values. You need to enter these values each time you make a request.</li>
	<li>In the <b>URL</b> field, enter the URL to which the API call will be performed and select the required HTTP method.</li>
	<li>In the <b>Headers</b> table, click <b>Add row</b> and add the Accept - application/json or Accept - text/xml header depending on which format you prefer for the returned data.</li>
	<li>Click <b>Send Request</b>.</li>
</ol>


<p><b>Example: Retrieving the list of customers</b></p>

<ol>
	<li>In the <b>Method</b> group of options, select the <b>GET</b> option.</li>
	<li>In the URL field, enter the following URL: <a href="http://magentohost/api/rest/customers">http://magentohost/api/rest/customers</a>.</li>
	<li>Click <b>Send request</b>. Information about all customers will be displayed in the response body. Note that only Admin type of the user can retrieve the list of customers. Example is as follows:<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test11.png" style="border: 1px solid black"/></span></li>
</ol>


<p><b>Example: Creating a customer address</b></p>

<ol>
	<li>In the <b>Method</b> group of options, select the <b>POST</b> option.</li>
	<li>In the URL field, enter the following URL: <a href="http://magentohost/api/rest/customers/:id/addresses">http://magentohost/api/rest/customers/:id/addresses</a> where the ":id" value is the customer ID in the system.</li>
	<li>In the <b>Body</b> table, on the <b>Raw input</b> tab, enter the data required for customer address creation.</li>
	<li>Click <b>Send request</b>. If the address is created, the 200 OK HTTP status code will be returned. Example is as follows:<br/>
<img src="{{ site.baseurl }}/common/images/m1x/rest_test12.png" style="border: 1px solid black"/></span></li>
</ol>
